package com.pyz.thread.version.threadpool;

import java.util.Date;

/**
 * @author yinzhenpu
 * @date 2022/6/4 18:08:59
 * @description 这是一个简单的Runnable类，需要大约5秒钟来执行其任务。
 */
public class MyRunnable implements Runnable {

    private String command;

    public MyRunnable(String s) {
        this.command = s;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " 开始");
        processCommand();
        System.out.println(Thread.currentThread().getName() + " 结束");
    }

    private void processCommand() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return this.command;
    }
}

